package com.example.onlineeducation.net

import com.example.onlineeducation.App
import com.example.onlineeducation.BuildConfig
import com.example.onlineeducation.data.json.*
import com.yc.jetpacklib.init.YcJetpack
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*

/**
 * SimpleDes:
 * Creator: Sindi
 * Date: 2022-04-14
 * UseDes:
 */
interface ApiService {
    /**
     * 版本更新
     */
    @GET("clientPackage/getClientVersion")
    suspend fun getVersion(
        @Query("clientType") clientType: String = "1",
        @Query("channel") channel: String = App.mInstant.packageName,
        @Header(YcJetpack.OTHER_BASE_URL) otherUrl: String = BuildConfig.update_url,
    ): HttpVersionResponse<VersionJson?>

    /**
     * 登录
     */
    @FormUrlEncoded
    @POST("front/sms/sendCode")
    suspend fun sendCode(
        @Field("phone") phone: String
    ): HttpResponse<String?>

    /**
     * 登录
     */
    @POST("sys/phoneLogin")
    suspend fun login(
        @Body requestBody: RequestBody
    ): HttpResponse<LoginJson?>

    /**
     * 登出
     */
    @POST("/sys/logout")
    suspend fun logout(): HttpResponse<String?>

    /**
     * 注册
     */
    @POST("person/add/front")
    suspend fun register(
        @Body requestBody: RequestBody
    ): HttpResponse<String?>

    /**
     * 注册-获取项目列表
     */
    @GET("project/projectInfo/page/front")
    suspend fun getProList(
        @Query("name") proId: String,
        @Query("pageNo") pageIndex: Int,//第几页
        @Query("pageSize") pageSize: Int//每页显示几条数据
    ): HttpResponsePageList<RegisterProListJson>

    /**
     * 注册-获取班组列表
     */
    @GET("person/group/page/front")
    suspend fun getGroupList(
        @Query("name") name: String,
        @Query("projId") projId: String,
        @Query("pageNo") pageIndex: Int,//第几页
        @Query("pageSize") pageSize: Int//每页显示几条数据
    ): HttpResponsePageList<RegisterGoupListJson>

    /**
     * 注册-获取工种列表
     */
    @GET("person/type/page/front")
    suspend fun getWorkTypeList(
        @Query("name") name: String,
        @Query("pageNo") pageIndex: Int,//第几页
        @Query("pageSize") pageSize: Int//每页显示几条数据
    ): HttpResponsePageList<RegisterWorkTypeListJson>

    /**
     * 获取用户信息
     */
    @GET("front/person/info")
    suspend fun getUserInfo(): HttpResponse<UserInfoJson?>

    /**
     * 积分记录列表
     */
    @GET("points/pointsDetails/list/front")
    suspend fun getScoreRecordList(
        @Query("pageNo") pageIndex: Int,//第几页
        @Query("pageSize") pageSize: Int//每页显示几条数据
    ): HttpResponsePageList<ScoreRecordListJson>

    /**
     * 证书列表
     */
    @GET("front/show/Cert")
    suspend fun getCertificateList(
        @Query("projId") proId: String,
        @Query("pageNo") pageIndex: Int,//第几页
        @Query("pageSize") pageSize: Int//每页显示几条数据
    ): HttpResponsePageList<CertificateListJson>

    /**
     * 获取错题学习列表
     */
    @GET("/front/topic/errorList")
    suspend fun getErrorList(
        @Query("projId") proId: String,
    ): HttpResponseList<TopicJson>


    /**
     * 考试记录列表
     */
    @GET("front/exam/examLog")
    suspend fun getExamRecordList(
        @Query("projId") proId: String,
        @Query("pageNo") pageIndex: Int,//第几页
        @Query("pageSize") pageSize: Int//每页显示几条数据
    ): HttpResponsePageList<ExamRecordListJson>

    /**
     * 考试记录——结果详情
     */
    @GET("front/exam/answerInfo")
    suspend fun getExamResultDetail(
        @Query("examLogId") examLogId: String,//考试记录id
    ): HttpResponse<ExamResultDetailJson?>

    /**
     * 推送学习记录
     */
    @POST("front/study/pushLog")
    suspend fun pushStudyLog(
        @Body requestBody: RequestBody
    ): HttpResponse<Any?>


    /**
     * 获取专题列表
     */
    @GET("front/topic/infoList")
    suspend fun getTopicList(
        @Query("projId") projId: String,//项目id
        @Query("name") name: String? = "",//关键字
        @Query("isPass") isPass: String? = null,//是否达标
        @Query("groupId") groupId: String? = null,//分组id
    ): HttpResponseList<TopicJson>

    /**
     * 获取考试列表
     */
    @GET("front/exam/examInfo")
    suspend fun getExamList(
        @Query("projId") projId: String,//项目id
        @Query("examName") name: String? = "",//关键字
        @Query("type") groupId: String? = null//分组ID
    ): HttpResponseList<ExamJson>

    /**
     * 在线考试扫一扫
     */
    @GET("/front/exam/examInfoAndTopicInfo")
    suspend fun getExamInfoAndTopicInfo(
        @Query("examId") examId: String,//考试id
        @Query("topicId") topicId: String,//专题id
        @Query("projId") examLogId: String,//项目id
    ): HttpResponse<ExamAndTopicJson?>

    /**
     * 点击考试前获取学习时间看是否达标
     */
    @GET("front/exam/checkStudyTime")
    suspend fun getCheckStudyTime(
        @Query("projId") projId: String,//项目id
        @Query("topicId") topicId: String//专题ID
    ): HttpResponse<String?>

    /**
     * 获取线下活动-学习活动列表
     * @param projId String         项目id
     */
    @GET("front/active/all")
    suspend fun getOfflineStudyLiveList(
        @Query("projId") projId: String
    ): HttpResponseList<OfflineStudyLiveListJson>

    /**
     * 获取线下活动-已参加列表
     */
    @GET("front/active/joinActive")
    suspend fun getOfflineJoinActiveList(
        @Query("projId") projId: String//项目id
    ): HttpResponseList<OfflineStudyLiveListJson>

    /**
     * 获取线下活动-学习活动详情
     * @param projId String         项目id
     * @param studyLiveId String    学习活动id
     */
    @GET("front/active/activeById")
    suspend fun getOfflineStudyLiveDetail(
        @Query("projId") projId: String,
        @Query("activeInfoId") studyLiveId: String,
    ): HttpResponse<OfflineStudyLiveDetailJson>

    /**
     * 线下学习活动-签到/签退
     * @param studyLiveId String    线下学习活动id
     * @param address String        签到点的地址
     * @param lat String            签到点的纬度
     * @param lng String            签到点的经度
     * @param userName String       签到用户名称
     * @param userPhone String      签到用户手机号
     * @param signType String       签到类型 1-签到 2-签退
     */
    @POST("front/active/personSign")
    suspend fun offlineStudyLiveSignInOrSignOut(@Body data: RequestBody): HttpResponse<String>

    /**
     * 获取线上考试题目列表
     */
    @GET("front/exam/examQuestions")
    suspend fun getExaminationProblemList(
        @Query("examId") examinationId: String//项目id
    ): HttpResponseList<OnlineExaminationQuestionsJson>

    /**
     * 完成线上考试
     */
    @POST("front/exam/examResultMsg")
    suspend fun getExaminationFinish(
        @Body requestBody: RequestBody
    ): HttpResponse<OnlineExaminationFinishJson?>

    /**
     * 练习-题目列表
     */
    @GET("front/study/questionList")
    suspend fun getPractiseQuestionList(
        @Query("chapterId") chapterId: String,//章节id
    ): HttpResponseList<PractiseQuestionJson>


    /**
     * 练习——提交答案
     */
    @POST("front/study/pushQuestion")
    suspend fun submitPractiseOptions(
        @Body requestBody: RequestBody
    ): HttpResponseList<String>

    /**
     * 首页轮播图
     */
    @GET("front/show/banner")
    suspend fun getBanner(
        @Query("projId") projId: String,//项目id
    ): HttpResponseList<BannerJson>


    /**
     * 首页公告栏通知
     */
    @GET("front/show/notice")
    suspend fun getNotice(
        @Query("projId") projId: String,//项目id
    ): HttpResponseList<NoticeListJson>


    /**
     * 素材列表
     */
    @GET("front/study/chapterList")
    suspend fun getChapterList(
        @Query("projId") proId: String,//项目ID
        @Query("topicId") topicId: String//专题id
    ): HttpResponseList<ChapterJson>


    /**
     * 学习计划列表
     */
    @GET("front/topic/groupList")
    suspend fun getStudyPlanList(
        @Query("projId") proId: String,//项目ID
    ): HttpResponseList<StudyPlanListJson>

    /**
     * 获取热门搜索
     */
    @GET("front/show/hotSearch")
    suspend fun getHotSearch(
    ): HttpResponseList<HotSearchJson>



    /*
    * 多文件上传
    */
    @POST("sys/common/uploadFiles")
    @Multipart
    suspend fun uploadMultipleFile(
        @Part partLis: List<MultipartBody.Part>
    ): HttpResponse<UploadMultipleFileResultJson?>


    /*
    * 单文件上传
    */
    @POST("sys/common/upload")
    @Multipart
    suspend fun uploadFile(
        @Part partLis: List<MultipartBody.Part>
    ): HttpResponse<UploadFileResultJson?>

    /*
    * 提交线下考试详情
    * */
    @PUT("examlogoffline/ksExamLogOffline/edit")
    suspend fun submitOfflineExamDetail(
        @Body requestBody: RequestBody
    ): HttpResponse<Any?>

    /**
     * 线下考试列表
     */
    @GET("examinfooffline/ksExamInfoOffline/list")
    suspend fun getOfflineExamList(
        @Query("projIds") proId: String,
        @Query("pageNo") pageIndex: Int,//第几页
        @Query("pageSize") pageSize: Int//每页显示几条数据
    ): HttpResponsePageList<OfflineExamListJson>

    /**
     * 线下考试_人员考试记录列表
     */
    @GET("examlogoffline/ksExamLogOffline/list")
    suspend fun getOfflineExamRecordList(
        @Query("projId") proId: String? = null,
        @Query("examId") examId: String? = null,//考试id
        @Query("id") id: String? = null,//人员考试记录id
        @Query("personName") personName: String? = null,
        @Query("pageNo") pageIndex: Int,//第几页
        @Query("pageSize") pageSize: Int//每页显示几条数据
    ): HttpResponsePageList<OfflineExamRecordListJson>

    /**
     * 登录
     */
    @FormUrlEncoded
    @POST("front/sms/sendSignSmsCode")
    suspend fun sendSignSmsCode(
        @Field("phone") phone: String
    ): HttpResponse<String?>

    /**
     *
     * 线下活动-获取代签到列表
     */
    @GET("front/active/replaceSign")
    suspend fun getReplaceSignList(
        @Query("activeInfoId") activeInfoId: String//活动ID
    ): HttpResponseList<ReplaceSignListJson>

    /**
     * 线下活动_代签到
     */
    @POST("front/active/replaceSign")
    suspend fun replaceSign(
        @Body requestBody: RequestBody
    ): HttpResponse<String>

    /**
     * 获取用户在x项目的学习时长
     */
    @GET("front/topic/times")
    suspend fun getUserProStudyTime(
        @Query("projId") proId: String
    ): HttpResponse<UserProStudyTimeJson>

    /**
     * 获取用户在x项目的参加活动信息
     */
    @GET("front/show/joinInfo")
    suspend fun getJoinInfo(
        @Query("projId") proId: String
    ): HttpResponse<UserProJoinInfoJson>

    /**
     * 获取用户在x项目的学习情况图表数据
     */
    @GET("front/topic/dashboard")
    suspend fun getUserProStudyChar(
        @Query("projId") proId: String, @Query("begin") timeStart: String, @Query("end") timeEnd: String
    ): HttpResponse<UserProStudyChartJson>
}